package com._520it.crm.service.impl;

import com._520it.crm.domain.ClassInfo;
import com._520it.crm.mapper.ClassInfoMapper;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.ClassInfoQueryObject;
import com._520it.crm.service.IClassInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class ClassInfoServiceImpl implements IClassInfoService {
	@Autowired
	private ClassInfoMapper classInfoMapper;

	public void deleteByPrimaryKey(Long id) {
		classInfoMapper.deleteByPrimaryKey(id);
	}
	public void insert(ClassInfo record) {
		classInfoMapper.insert(record);
	}

	public ClassInfo selectByPrimaryKey(Long id) {
		return classInfoMapper.selectByPrimaryKey(id);
	}

	public List<ClassInfo> selectAll() {
		return classInfoMapper.selectAll();
	}

	public void updateByPrimaryKey(ClassInfo record) {
		classInfoMapper.updateByPrimaryKey(record);
	}

	public PageResult queryPage(ClassInfoQueryObject qo) {
		Integer count = classInfoMapper.queryPageCount(qo);
		if(count <= 0){
			return new PageResult(0, Collections.EMPTY_LIST);
		}
		List<ClassInfo> result =  classInfoMapper.queryPageData(qo);
		return new PageResult(count, result);
	}
}
